package com.samoyed.credit;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;

import androidx.annotation.Nullable;

/**
 * @author longke
 * @date: 2021/10/30 19:12
 * @corporation: 深圳萨摩耶互联网金融服务公司
 * @description：
 */
public class BaseActivity extends Activity {
    private ProgressDialog progressDialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    public void showPregressDialog(String s) {
        showLoadingDialog(s);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {

                dismissLoadingDialog();
                finish();
            }
        }, 2000);
    }

    public void showLoadingDialog(String message) {
        progressDialog = new ProgressDialog(this);
        //设置提示信息

        progressDialog.setMessage(message);


// 能够返回

        progressDialog.setCancelable(false);

// 点击外部返回

        progressDialog.setCanceledOnTouchOutside(true);

//设置进度条

        progressDialog.setProgress(100);

//设置进度条是否明确

        progressDialog.setIndeterminate(true);

//设置进度条样式

//ProgressDialog.STYLE_SPINNER 环形精度条

//ProgressDialog.STYLE_HORIZONTAL 水平样式的进度条

        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.show();


    }

    public void dismissLoadingDialog() {
        if (null != progressDialog && progressDialog.isShowing()) {
            progressDialog.dismiss();
        }
    }
}
